// 导入api.js
import http from './http';

export const login = (params) => http.post('/login/login', params);
export const getCurrentUserInfo = () => http.post('/login/getCurrentUserInfo');
export const logout = () => http.post('/logout');
export const getFormatOptions = () => http.get('/conf/getFormatCodes');
export const getPlcTypeOptions = () => http.get('/conf/getPLCTypes');

export const getDeviceStatus = () => http.get('/status/getAllStatus');

export const getNetworkInfo = () => http.get('/conf/getNetworkInfo');
export const setNetworkInfo = (params) => http.post('/conf/setNetworkInfo', params);

export const getHsmsInfo = () => http.get('/conf/getHsmsInfo');
export const setHsmsInfo = (params) => http.post('/conf/setHsmsInfo', params);

export const findDidByName = (params) => http.post('/conf/findDidByName', params);
export const setDid = (params) => http.post('/conf/setDid', params);

export const findSvidByName = (params) => http.post('/svid/findSvidByName', params);
export const setSvid = (params) => http.post('/svid/setSvid', params);
export const delSvids = (params) => http.post('/svid/delSvids/', params);

export const findEcidByName = (params) => http.post('/ecid/findEcidByName', params);
export const setEcid = (params) => http.post('/ecid/setEcid', params);
export const delEcids = (params) => http.post('/ecid/delEcids/', params);

export const findAlarmByName = (params) => http.post('/alarm/findAlarmByName', params);
export const setAlarm = (params) => http.post('/alarm/setAlarm', params);
export const delAlarm = (params) => http.post('/alarm/delAlarms', params);

export const findRptidByName = (params) => http.post('/rptid/findRptidByName', params);
export const setRptid = (params) => http.post('/rptid/setRptid', params);
export const delRptids = (params) => http.post('/rptid/delRptids', params);

export const findCeidByName = (params) => http.post('/ceid/findCeidByName', params);
export const setCeid = (params) => http.post('/ceid/setCeid', params);
export const delCeids = (params) => http.post('/ceid/delCeids', params);

export const findHCmdByName = (params) => http.post('/hcmd/findHCmdByName', params);
export const setHCmd = (params) => http.post('/hcmd/setHCmd', params);
export const delHCmds = (params) => http.post('/hcmd/delHCmds', params);

export const findHCPByName = (params) => http.post('/hcp/findHCPByName', params);
export const setHCP = (params) => http.post('/hcp/setHCP', params);
export const delHCPs = (id, params) => http.post(`/hcp/delHCPs/${id}`, params);

export const findTrtByName = (params) => http.post('/trt/findTrtByName', params);
export const setTrt = (params) => http.post('/trt/setTrt', params);
export const delTrts = (params) => http.post('/trt/delTrts', params);

export const testPLC = () => http.get('/conf/testPLC');
export const getPlcConf = () => http.get('/conf/getPlcConf');
export const setPlcConf = (params) => http.post('/conf/setPlcConf', params);

export const setLogInfo = (params) => http.post('/conf/setLogInfo', params);
export const getLogInfo = () => http.get('/conf/getLogInfo');

export const exportCSV = (params) => http.get(params);
// export const allex = () => http.get('/conf/fullExport');

export const uploadFile = (url, file) => http.uploadFile(url, file);

export const setS3F17Info = (params) => http.post('/S3F17/setS3F17Info', params);
export const getS3F17Info = () => http.get('/S3F17/getS3F17Info');

export const setS7F19Info = (params) => http.post('/S7F19/setS7F19Info', params);
export const getS7F19Info = () => http.get('/S7F19/getS7F19Info');

export const setS7F25Info = (params) => http.post('/S7F25/setS7F25Info', params);
export const getS7F25Info = () => http.get('/S7F25/getS7F25Info');

export const setS7F23Info = (params) => http.post('/S7F23/setS7F23Info', params);
export const getS7F23Info = () => http.get('/S7F23/getS7F23Info');

export const exportS3F17Conf = () => http.get('/S3F17/exportJSON');
export const importS3F17Conf = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return http.post('/S3F17/importJSON', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
};

export const exportS7F19Conf = () => http.get('/S7F19/exportJSON');
export const importS7F19Conf = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return http.post('/S7F19/importJSON', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
};

export const exportS7F23Conf = () => http.get('/S7F23/exportJSON');
export const importS7F23Conf = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return http.post('/S7F23/importJSON', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
};

export const exportS7F25Conf = () => http.get('/S7F25/exportJSON');
export const importS7F25Conf = (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return http.post('/S7F25/importJSON', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
};
